<template>
    <div class="me">
        <div class="person-head">
            <img src="../../assets/img/me/header.png" class="header-img" />
            <p class="person-name">{{company}}</p>
            <p class="person-intro" v-if="level==1">钻石代理商</p>
            <p class="person-intro" v-if="level==2">金牌代理商</p>
            <p class="person-intro" v-if="level==3">超级节点</p>
            <p class="person-intro" v-if="level==4">普通节点</p>
        </div>
        <div class="person-momey" v-if="level==1 || level==2">
            <div class="money-order" >
                <p class="money-intro">我的预付金</p>
                <p class="money-intro" style="border-right:1px solid #ccc;">￥{{totalAccount}}</p>
            </div>
            <div class="money-order">
                <p class="money-intro">我的收入</p>
                <p class="money-intro">￥{{totalIncome}}</p>
            </div>
        </div>
         <div class="person-momey-putong" v-if="level==3 || level==4">
             我的收入:￥{{totalIncome}}
        </div>
        <div class="person-option">
            <mt-cell title="我的订单" to="/my_order" is-link class="person-cell" v-if="level == 1 || level == 2">
                <img slot="icon" src="../../assets/img/me/me_order.png" width="20" height="20">
            </mt-cell>
            <mt-cell title="我的席位" to="/seat" is-link class="person-cell" v-if="level == 1 || level == 2">
                <img slot="icon" src="../../assets/img/me/me_seat.png" width="20" height="20">
            </mt-cell>
            <!-- <mt-cell title="我的二维码" to="/qrcode" is-link class="person-cell" v-if="level == 2">
                <img slot="icon" src="../../assets/img/me/qrcode.png" width="20" height="20">
            </mt-cell> -->
            <mt-cell title="我的代理商" to="/my_business" is-link class="person-cell" v-if="level == 1">
                <img slot="icon" src="../../assets/img/me/me_business.png" width="20" height="20">
            </mt-cell>
            <mt-cell title="提现" to="/tixian" is-link class="person-cell">
                <img slot="icon" src="../../assets/img/me/me_money.png" width="20" height="20">
            </mt-cell>
            <mt-cell title="设置" to="/my_setting" is-link class="person-cell">
                <img slot="icon" src="../../assets/img/me/me_setting.png" width="20" height="20"></mt-cell>
        </div>
        <com-footer currentIndex="2"></com-footer>
    
    </div>
</template>
<script>
    import comFooter from '../../components/comFooter'
    import { post } from '../../../util/http.js'
    import { Toast } from 'mint-ui'
    export default {
        components: {
            comFooter
        },
        data () {
            return {
                totalAccount: '',
                totalIncome: '',
                company: '',
                level: 1   // 1:钻石 2:金牌 3:超级节点 4:普通节点
            }
        },
        created() {
            this.level = JSON.parse(window.localStorage.getItem('dongHang_data')).level
            let info = JSON.parse(window.localStorage.getItem('dongHang_data'))
            this.company = JSON.parse(window.localStorage.getItem('dongHang_data')).company
            this.$nextTick(()=>{
                post('http://dlsapi.rz158.com/dataShow/IncomAndExpenses', {
                    agentId: info.agentId
                }).then(res => {
                    if(res.code == 0) {
                        this.totalIncome = res.t.totalIncome
                        // this.totalAccount = res.t.totalAccount
                        window.localStorage.setItem('shouru', res.t.totalIncome)
                    } else {
                        Toast({
                            message: res.message,
                            duration: 1000
                        })
                    }
                })
                post('http://dlsapi.rz158.com/agent/myAccountInfo', {
                    agentId: info.agentId
                }).then(res => {
                    this.totalAccount = res.t
                })
            })
        }
    }
</script>
<style lang="less" scoped>
    .me {
        background: #efefef;
        .person-head {
            height: 3.66rem;
            background: blue;
            width: 100%;
            background: url('../../assets/img/me/bg.png') no-repeat;
            background-size: 100%;
            text-align: center;
            color: #000;
            .header-img {
                margin-top: .7rem;
                width: 1.26rem;
                height: 1.26rem;
                border-radius: 50%;
            }
            .person-name {
                font-size: .32rem;
                padding-top: .1rem;
                padding-bottom: .1rem;
            }
            .person-intro {
                font-size: .28rem;
            }
        }
        .person-momey {
            height: 1rem;
            background: #fff;
            display: flex;
            text-align: center;
            padding: .3rem 0rem;
            margin-bottom: .12rem;
            .money-order {
                width: 3.75rem;
                height: 100%;
                .money-intro {
                    font-size: .3rem;
                    padding: .05rem 0rem;
                }
            }
        }
        .person-option {
            background: #fff;
            padding-left: .3rem;
            .person-cell {
                border-bottom: 1px solid #cccccc;
            }
        }
    }
    .person-momey-putong{
        font-size: .34rem;
        padding-left: .6rem;
        height: .9rem;
        line-height: .9rem;
        background: #fff;
        border-bottom: 4px solid #cccccc;
    }

</style>

